<template>
  <t-layout-page-item>
    <t-select-table
      :table="state.table"
      :columns="state.table.columns"
      :max-height="400"
      isShowPagination
      :keywords="{ label: 'khmc', value: 'khbm' }"
      @radioChange="radioChange"
      @page-change="pageChange"
    />
  </t-layout-page-item>
</template>
<script setup lang="tsx">
import { reactive, onMounted } from "vue";
import { ElMessageBox } from "element-plus";
import axios from "../axios/axiosInstance";

const state: any = reactive({
  table: {
    total: 0,
    currentPage: 1,
    data: [],
    columns: [
      { prop: "id", label: "数据来源", minWidth: "100" },
      { prop: "khbm", label: "最后更新日期", minWidth: "100" },
      { prop: "khmc", label: "最后更新人", minWidth: "100" },
    ],
  },
});
onMounted(() => {
  getData(1);
});
const getData = async (pageNum) => {
  axios({
    url: "/get/Kh",
    method: "post",
    data: {
      page: 1,
      limit: 10,
    },
  }).then((res) => {
    console.log(res.data);
    state.table.data = res.data;
  });
};
// 获取当前的页码
const pageChange = (val) => {
  console.log("获取当前的页码", val);
  state.table.currentPage = val;
  getData(val);
};
const handleStatusChange = (row) => {
  let text = row.enableStatus === 1 ? "启用" : "废止";
  ElMessageBox.confirm(`确认要${text}这条数据吗？`, "警告", {
    confirmButtonText: "确定",
    cancelButtonText: "取消",
    type: "warning",
  })
    .then(async () => {
      console.log("点击确定");
    })
    .catch(() => {
      console.log("点击确定");
    });
};
const radioChange = (row) => {
  console.log("单选--传给后台的值", row);
};
</script>
<style scoped></style>
